#include<stdio.h>
#include<stdlib.h>
#include<sys/types.h>
#include<sys/wait.h>
#include<unistd.h>
#include<assert.h>

int main(int argc,char* argv[])
{
    printf("child process runing...\n");
    pid_t id=fork();
    assert(id!=-1);
    if(id==0)
    {
       sleep(1);
       //execl("/usr/bin/ls","ls","-l",NULL);
       execlp("ls","ls","-a","-l","--color=auto",NULL);
       exit(0);
    }
    int status;
    pid_t ret=waitpid(id,&status,0);
    if(ret>0)
        printf("wait success: exit code:%d  sig:%d\n",(status>>8)&0xFF,status&0x7F);
    return 0;
}
